package org.chouy.web.controller;


import com.alibaba.druid.support.json.JSONUtils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;

import org.chouy.framework.datasource.DynamicDataSource;
import org.chouy.framework.datasource.DynamicDataSourceContextHolder;
import org.chouy.system.domain.SysDept;
import org.chouy.system.domain.SysUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import org.chouy.system.service.ISysUserService;


/**
 * @author zhouyang
 */
@Controller
@RequestMapping("/yang")
public class HelloController {


    @Autowired
    private ISysUserService iSysUserService;



    @RequestMapping(value = {"/hello/{userName}","/hi/{userName}"},method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
    @ResponseBody
    public String sayHello(@PathVariable(name = "userName") String userName){
        //DynamicDataSourceContextHolder.setDataSourceType("MASTER");
        //DynamicDataSourceContextHolder.setDataSourceType("SLAVE");
        SysUser sysUser = iSysUserService.selectUserByLoginName(userName);

        //String userJson = JSON.toJSONString(sysUser);
        //SysDept sysDept = iSys
        return StringUtils.isEmpty(sysUser) ? "空的" : sysUser.toString();

//        return applicationPropertiesBean.getType();
    }

    //@RequestMapping(value = "/system/user",method = RequestMethod.GET)
    @GetMapping
    public String userList(){
        return "system/user/list";
    }


}
